﻿using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Wexflow.Core
{
    internal class JobListener: IJobListener
    {
        public string Name => "hello joblisener";

        //job被拒绝时执行
        public async System.Threading.Tasks.Task JobExecutionVetoed(IJobExecutionContext context, CancellationToken cancellationToken = default(CancellationToken))
        {
            await System.Threading.Tasks.Task.Run(() => { });
        }

        //job开始前执行
        public async System.Threading.Tasks.Task JobToBeExecuted(IJobExecutionContext context, CancellationToken cancellationToken = default(CancellationToken))
        {
            await System.Threading.Tasks.Task.Run(() =>
            {
                Console.WriteLine("myjob-------------begin");
            });
        }

        //job完成后执行
        public async System.Threading.Tasks.Task JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException, CancellationToken cancellationToken = default(CancellationToken))
        {
            await System.Threading.Tasks.Task.Run(() =>
            {
                Console.WriteLine("myjob---------------end");
                Console.WriteLine();
            });
        }
    }
}
